package priv.mill.mapper;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;

import priv.mill.mapper.annotation.Delete;
import priv.mill.util.JdbcUtil;

@Delete(value="delete from employee where id=?",args={"id"})
public class EmployeeInsertMapper extends HttpServlet{

	private static Logger logger = Logger.getLogger(EmployeeInsertMapper.class);
	
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		try {
			boolean update = JdbcUtil.update("insert into employee "
					+ "(u_name , u_phone , u_age, u_salary, jiangjin, d_id) "
					+ "values( ? , ? , ?, ?, ?, ?)", 
					req.getParameter("u_name"),
					req.getParameter("u_phone"),
					req.getParameter("u_age"),
					req.getParameter("u_salary"),
					req.getParameter("jiangjin"),
					req.getParameter("d_id")
					);
			if(update) {
				resp.getWriter().println("success");
			}else {
				resp.getWriter().println("fail");
				
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	
	
}


